﻿<UserControl x:Class="BizControl.Presentation.ActivityEditModule.Views.CommentsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:controls="clr-namespace:BizControl.Presentation.Infrastructure.Controls;assembly=BizControl.Presentation.Infrastructure"
             xmlns:csla="clr-namespace:Csla.Xaml;assembly=Csla.Xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008">

    <UserControl.Resources>
        <DataTemplate x:Key="CommentsListBoxTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="150" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <StackPanel>
                    <controls:CurrentUserControl VerticalAlignment="Top" HorizontalAlignment="Left" 
                                                 DataContext="{Binding CreatedBy}" />
                    <TextBlock Text="{Binding Date}" TextWrapping="Wrap"
                               Margin="2" FontSize="10pt" FontWeight="Bold" VerticalAlignment="Top" HorizontalAlignment="Left" />
                    <ComboBox Grid.Column="1" Height="25" FontSize="10pt" FontWeight="Bold" Margin="5"
                              VerticalAlignment="Center" HorizontalAlignment="Left"
                              ItemsSource="{Binding ElementName=CommentsListBox, Path=DataContext.Priorities}"
                              DisplayMemberPath="Key"
                              SelectedValuePath="Value"
                              ToolTip="Приоритет"
                              IsEnabled="{Binding Path=IsNew}" 
                              SelectedValue="{Binding Path=Priority, Mode=TwoWay}" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" Grid.Column="1">
                    <csla:PropertyStatus Grid.Column="1" Margin="5" Property="{Binding Path=Text}"/>
                    <TextBox IsReadOnly="{Binding Path=IsNew, Converter={StaticResource TrueToFalseConverter}}" 
                             Text="{Binding Text, UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap"
                             Width="340" Margin="2" FontSize="10pt" FontWeight="Bold" MinHeight="75"
                             HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                </StackPanel>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Auto">
            <Border BorderBrush="Black" BorderThickness="1" Margin="5" CornerRadius="5">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="40" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Button Width="25" Height="25" Margin="5"
                        ToolTip="Добавить комментарий"
                        Command="{Binding AddCommentCommand}"
                        HorizontalAlignment="Right" VerticalAlignment="Center" 
                        Content="{StaticResource PlusPath}"/>
                    <ListBox Name="CommentsListBox" Background="{x:Null}" Grid.Row="1"
                             ItemsSource="{Binding IsAsync=True, Path=Model}" Style="{StaticResource DefaultListBoxStyle}"
                             ItemTemplate="{StaticResource CommentsListBoxTemplate}" HorizontalContentAlignment="Stretch">
                    </ListBox>
                </Grid>
            </Border>
    </ScrollViewer>
</UserControl>
